<template>
  <div>
    <div class="main w">
      <div class="mainTitle">
        <span>
          机关教辅单位服务作风评价 -
          <i class="voting">集中评价结果</i>
        </span>
      </div>
      <div class="left1">
        <div class="department">
          <ul>
            <li
              :class="itemClass == index ? 'active':''"
              v-for="(item,index) in vestinList "
              :key="item.depid"
              @click="getItme(item,index) "
            >
              <!-- <router-link
                :to="'/departentResult/'+item.depid"
                :class="itemClass == index ? 'active':''"
              >-->
              <!-- 另一种表达式 -->
              <!-- <router-link
                :to="'/departentResult/'+item.depid"
                :class="{'active':itemClass == index}"
              >
                <span class="departementName">{{item.name}}</span>
              </router-link> -->
              <!-- <router-link
                :to="'/departentResult/'+item.depid"
                :class="{'active':itemClass == index}"
              > -->
                <span class="departementName">{{item.name}}</span>
              <!-- </router-link> -->
            </li>
          </ul>
        </div>
      </div>
      <router-view/>
    </div>
  </div>
</template>
<script>
import bus from "../../components/common";
export default {
  name: "selfPage",
  data() {
    return {
      vestinList: [],
      itemClass: 0
    };
  },
  created() {
    this.getVestinList();
  },
  mounted() {
    //部门列表高亮显示
    if (this.$route.params.depId - 1) {
      this.itemClass = this.$route.params.depId - 1;
    } else {
      this.itemClass = 0;
    }
  },
  methods: {
    
    //获取部门列表
    getVestinList() {
      this.axios.get("api/department/statistics/findAllEnable").then(response => {
        this.vestinList = response.data;
        // console.log("部门列表", this.vestinList);
          var firstId = this.vestinList[0].depid;
          // console.log("669",firstId);
          bus.$emit("depFirstId", firstId); // bus发送第一个部门Id
      });
    },

    //部门列表点击时样式
    getItme(item,index) {
      // console.log("urlId",item);
      this.itemClass = index; // 把当前点击元素的index，赋值给itemClass
      this.$router.push({
          name: 'departentResult',
          query: {
            depId: item.depid,
            isParticipation:item.isParticipation
          }
        })
      //点击下一页时让页面返回顶部
      document.body.scrollTop = 0;
      document.documentElement.scrollTop = 0;
    }
  }
};
</script>